// import Home from '../pages/Home'
const Home = () => import('../pages/Home')
// import Login from '../pages/Login'
const Login = () => import('../pages/Login')
// import Register from '../pages/Register'
const Register = () => import('../pages/Register')
import Search from '../pages/Search'
import Detail from '@/pages/Detail'
import AddCartSuccess from '@/pages/AddCartSuccess'
import ShopCart from '@/pages/ShopCart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import PaySuccess from '@/pages/PaySuccess'
import Center from '@/pages/Center'
import MyOrder from '@/pages/Center/MyOrder'
import GroupOrder from '@/pages/Center/GroupOrder'



export default [
    {
        path: '/center',
        component: Center,
        children: [
            {
                path: 'myorder',
                component: MyOrder
            },
            {
                path: 'grouporder',
                component: GroupOrder
            },
            {
                path: '',
                redirect: 'myorder'
            }
        ]
    },


    {
        path: '/paysuccess',
        component: PaySuccess,
        // 路由独享守卫

        beforeEnter: (to, from, next) => {
            // console.log(from.path);
            if (from.path === '/pay') {
                next()
            } else {
                next(false)
            }
        }
    },


    {
        path: '/pay',
        component: Pay,
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path === '/trade') {
                next()
            } else {
                next(false)
            }
        }
    },

    {
        path: '/trade',
        component: Trade,
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path === '/shopCart') {
                next()
            } else {
                next(false)
            }
        }
    },
    {
        name: 'home',
        path: '/home',
        component: Home,
        meta: {
            isShowTypeNav: true
        }
    },
    {
        name: 'login',
        path: '/login',
        component: Login,
        meta: {
            isHiddenFooter: true
        }
    },
    {
        name: 'register',
        path: '/register',
        component: Register,
        meta: {
            isHiddenFooter: true
        }  // 这是一个用来存储额外数据的一个属性，可以通过这个属性做一些差异化的操作
    },
    {
        name: 'detail',
        path: '/detail/:id',
        component: Detail,
        props: true

    },
    {
        name: 'search', // 路由名称
        path: '/search/:keyword?',
        component: Search
    },
    {
        name: 'addcartsuccess',
        path: '/addCartSuccess',
        component: AddCartSuccess,
        beforeEnter: (to, from, next) => {
            let skuNum = to.query.skuNum
            let skuInfo = sessionStorage.getItem('skuInfo_key')
            if (skuNum && skuInfo) {
                next()
            } else {
                next('/')
            }
        }
    },
    {
        name: 'shopcart',
        path: '/shopCart',
        component: ShopCart
    },

    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/communication',
        component: () => import('@/pages/Communication/Communication'),
        children: [
            {
                path: 'event',
                component: () => import('@/pages/Communication/EventTest/EventTest'),
                meta: {
                    isHideFooter: true
                },
            },
            {
                path: 'model',
                component: () => import('@/pages/Communication/ModelTest/ModelTest'),
                meta: {
                    isHideFooter: true
                },
            },
            {
                path: 'sync',
                component: () => import('@/pages/Communication/SyncTest/SyncTest'),
                meta: {
                    isHideFooter: true
                },
            },
            {
                path: 'attrs-listeners',
                component: () => import('@/pages/Communication/AttrsListenersTest/AttrsListenersTest'),
                meta: {
                    isHideFooter: true
                },
            },
            {
                path: 'children-parent',
                component: () => import('@/pages/Communication/ChildrenParentTest/ChildrenParentTest'),
                meta: {
                    isHideFooter: true
                },
            },
            {
                path: 'scope-slot',
                component: () => import('@/pages/Communication/ScopeSlotTest/ScopeSlotTest'),
                meta: {
                    isHideFooter: true
                },
            }
        ],
    },
]